package com.pignest.hotel.beans;

import java.util.Date;

import org.apache.commons.lang.StringUtils;
import org.directwebremoting.annotations.RemoteProperty;

import com.pignest.hotel.annotation.Bean;
import com.pignest.hotel.beans.global.BaseBean;
import com.pignest.hotel.definition.MemberState;
import com.pignest.hotel.util.DateUtil;

@Bean("会员")
public class Member extends BaseBean {
	private static final long serialVersionUID = 4912745872031969263L;
	
	/*会员姓名*/
	private String name;
	
	private String type;
	
	private String sex;
	
	private String mobile;
	
	private String certificatType;
	
	private String certificateNo;
	
	private String mail;
	
	private String registerMode;
	
	private String sendCardWay;
	
	private String nation;
	
	private String province;
	
	private String street;
	
	private String post;
	
	private String cardNo;
	
	private MemberLevel memberLevel;
	//卡状态：在用、挂失
	private String state;
	
	private Date dealTime;//办理时间

	private Date birthday;
	
	private int credit;
	
	private int balance;
	
	private int integral;
	
	public Date getDealTime() {//办理时间//办理时间
		return dealTime;
	}

	public void setDealTime(Date dealTime) {
		this.dealTime = dealTime;
	}

	public Date getBirthday() {
		return birthday;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}

	public int getCredit() {
		return credit;
	}

	public void setCredit(int credit) {
		this.credit = credit;
	}

	public int getBalance() {
		return balance;
	}

	public void setBalance(int balance) {
		this.balance = balance;
	}

	public int getIntegral() {
		return integral;
	}

	public void setIntegral(int integral) {
		this.integral = integral;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	public String getCertificatType() {
		return certificatType;
	}

	public void setCertificatType(String certificatType) {
		this.certificatType = certificatType;
	}

	public String getCertificateNo() {
		return certificateNo;
	}

	public void setCertificateNo(String certificateNo) {
		this.certificateNo = certificateNo;
	}

	public String getMail() {
		return mail;
	}

	public void setMail(String mail) {
		this.mail = mail;
	}

	public String getRegisterMode() {
		return registerMode;
	}

	public void setRegisterMode(String registerMode) {
		this.registerMode = registerMode;
	}

	public String getSendCardWay() {
		return sendCardWay;
	}

	public void setSendCardWay(String sendCardWay) {
		this.sendCardWay = sendCardWay;
	}

	public String getNation() {
		return nation;
	}

	public void setNation(String nation) {
		this.nation = nation;
	}

	public String getProvince() {
		return province;
	}

	public void setProvince(String province) {
		this.province = province;
	}

	public String getStreet() {
		return street;
	}

	public void setStreet(String street) {
		this.street = street;
	}

	public String getPost() {
		return post;
	}

	public void setPost(String post) {
		this.post = post;
	}

	public String getCardNo() {
		return cardNo;
	}

	public void setCardNo(String cardNo) {
		this.cardNo = cardNo;
	}

	public MemberLevel getMemberLevel() {
		return memberLevel;
	}

	public void setMemberLevel(MemberLevel memberLevel) {
		this.memberLevel = memberLevel;
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}
	
	////////////////////////////////////////////////////////////////
	
	public String getDealTime2() {
		if (dealTime == null)
			return "";
		String b = DateUtil.toString(dealTime, DateUtil.DEFAULT_DATE_FORMAT);
		if (b == null)
			return "";
		return b;
	}
	
	@RemoteProperty
	public String getState2() {
		MemberState s = MemberState.valueof(state);
		if (s == null)
			return "";
		return s.getName();
	}
	
	public String getBirthday2() {
		if (birthday == null)
			return "";
		String b = DateUtil.toString(birthday, DateUtil.DEFAULT_DATE_FORMAT);
		if (b == null)
			return "";
		return b;
	}
	
	public String getAddress() {
		StringBuilder sb = new StringBuilder();
		sb.append(StringUtils.defaultString(province));
		sb.append(StringUtils.defaultString(nation));
		sb.append(StringUtils.defaultString(street));
		return sb.toString();
	}
	
	public String getDisplayName() {
		if (StringUtils.isEmpty(cardNo)) {
			return name;
		}
		return name + "(" + cardNo + ")";
	}
	
	@Override
	public String toSimpleString() {
		return concat(name, cardNo);
	}
	
}
